home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / FWGrUtil.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  4.9 KB  |  185 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWGrUtil.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWGRUTIL_H
  13. #include "FWGrUtil.h"
  14. #endif
  15.  
  16. #ifndef FWRECT_H
  17. #include "FWRect.h"
  18. #endif
  19.  
  20. #ifndef FWPOINT_H
  21. #include "FWPoint.h"
  22. #endif
  23.  
  24. #ifndef FWFXMATH_H
  25. #include "FWFxMath.h"
  26. #endif
  27.  
  28. #ifndef FWGCONST_H
  29. #include "FWGConst.h"
  30. #endif
  31.  
  32. #ifndef SLREGION_H
  33. #include "SLRegion.h"
  34. #endif
  35.  
  36. #ifndef FWODGEOM_H
  37. #include "FWODGeom.h"
  38. #endif
  39.  
  40. // ----- Foundation Includes -----
  41.  
  42. #ifndef FWPRIDEB_H
  43. #include "FWPriDeb.h"
  44. #endif
  45.  
  46. // ----- OpenDoc Includes -----
  47.  
  48. #ifndef SOM_ODShape_xh
  49. #include <Shape.xh>
  50. #endif
  51.  
  52. #ifndef SOM_ODTransform_xh
  53. #include <Trnsform.xh>
  54. #endif
  55.  
  56. // ----- C Includes -----
  57.  
  58. #if defined(FW_BUILD_MAC) & !defined(__FP__)
  59. #include <FP.h>
  60. #endif
  61.  
  62. #if defined(FW_BUILD_WIN) & !defined(__MATH_H)
  63. #include <Math.h>
  64. #endif
  65.  
  66. #ifdef FW_DEBUG
  67. #include <stdio.h>        // for sprintf()
  68. #endif
  69.  
  70. // ------ Platform includes ------
  71.  
  72. #if defined(FW_BUILD_MAC) & !defined(__QDOFFSCREEN__)
  73. #include <QDOffscreen.h>
  74. #endif
  75.  
  76. //========================================================================================
  77. //    RunTime Info
  78. //========================================================================================
  79.  
  80. #ifdef FW_BUILD_MAC
  81. #pragma segment FWGraphx_GrUtil
  82. #endif
  83.  
  84. //========================================================================================
  85. //    Global Methods
  86. //========================================================================================
  87.  
  88. //-------------------------------------------------------------------------
  89. // FW_CreateLineODShape
  90. //-------------------------------------------------------------------------
  91.  
  92. ODShape* FW_CreateLineODShape(Environment *ev, const FW_CPoint& from, const FW_CPoint& to, FW_Fixed penSize)
  93. {
  94.     FW_CPoint lineThickness(penSize, penSize);
  95.     
  96.     ODShape* shape = ::FW_NewODShape(ev);
  97.     ::FW_SetShapeRegion(ev, shape, ::FW_CreateLineRegion( from, to, lineThickness));
  98.     return shape;
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------
  102. //    FW_CreateOvalODShape
  103. //----------------------------------------------------------------------------------------
  104.  
  105. ODShape* FW_CreateOvalODShape(Environment *ev, const FW_CRect& rect)
  106. {
  107.     ODShape* shape = ::FW_NewODShape(ev);
  108.     ::FW_SetShapeRegion(ev, shape, ::FW_CreateOvalRegion(rect));
  109.     return shape;
  110. }
  111.  
  112. //----------------------------------------------------------------------------------------
  113. //    FW_CreateArcODShape
  114. //----------------------------------------------------------------------------------------
  115.  
  116. ODShape* FW_CreateArcODShape(Environment *ev, const FW_CRect& rect, short startAngle, short arcAngle)
  117. {
  118.     ODShape* shape = ::FW_NewODShape(ev);
  119.     ::FW_SetShapeRegion(ev, shape, ::FW_CreateArcRegion(rect, startAngle, arcAngle));
  120.     return shape;
  121. }
  122.  
  123. //----------------------------------------------------------------------------------------
  124. //    FW_CreateRoundRectODShape
  125. //----------------------------------------------------------------------------------------
  126.  
  127. ODShape* FW_CreateRoundRectODShape(Environment *ev, const FW_CRect& rect, const FW_CPoint& ovalSize)
  128. {
  129.     ODShape* shape = ::FW_NewODShape(ev);
  130.     ::FW_SetShapeRegion(ev, shape, ::FW_CreateRoundRectRegion(rect, ovalSize));
  131.     return shape;
  132. }
  133.  
  134. //----------------------------------------------------------------------------------------
  135. //    FW_OutlineODShape
  136. //----------------------------------------------------------------------------------------
  137.  
  138. void FW_OutlineODShape(Environment *ev, ODShape* odShapeToOutline, FW_Fixed outlineSize)
  139. {
  140.     ODShape* odTempShape = ::FW_NewODShape(ev, odShapeToOutline);
  141.     
  142.     if (outlineSize <= FW_kFixed0)
  143.         outlineSize = FW_kFixedPos1;
  144.         
  145.     odTempShape->Outset(ev, - FW_FixedToODFixed(outlineSize));
  146.     
  147.     odShapeToOutline->Subtract(ev, odTempShape);
  148.     odTempShape->Release(ev);
  149. }
  150.  
  151. #ifdef FW_BUILD_MAC
  152. //========================================================================================
  153. //    class FW_CMacTempPort
  154. //========================================================================================
  155.  
  156. FW_DEFINE_AUTO(FW_CMacTempPort)
  157.  
  158. //----------------------------------------------------------------------------------------
  159. //    FW_CMacTempPort::FW_CMacTempPort
  160. //----------------------------------------------------------------------------------------
  161.  
  162. FW_CMacTempPort::FW_CMacTempPort(GrafPtr tempPort /* = NULL */)
  163. {
  164.     ::GetPort(&fMacPort);
  165.  
  166.     if (tempPort != NULL)
  167.         SetPort(tempPort);
  168.         
  169.     FW_END_CONSTRUCTOR
  170. }
  171.  
  172. //----------------------------------------------------------------------------------------
  173. //    FW_CMacTempPort::~FW_CMacTempPort
  174. //----------------------------------------------------------------------------------------
  175.  
  176. FW_CMacTempPort::~FW_CMacTempPort()
  177. {
  178.     FW_START_DESTRUCTOR
  179.     
  180.     ::SetPort(fMacPort);
  181. }
  182.  
  183. #endif
  184.  
  185.